package chapter05.eventsourcehandler;

import java.util.HashMap;
import java.util.Map;
import java.util.Properties;

import org.osgi.framework.BundleActivator;
import org.osgi.framework.BundleContext;
import org.osgi.service.event.Event;
import org.osgi.service.event.EventAdmin;
import org.osgi.util.tracker.ServiceTracker;

public class Activator implements BundleActivator {

	public void start(BundleContext bundleContext) throws Exception {
		
		ServiceTracker tracker = new ServiceTracker(bundleContext, EventAdmin.class.getName(), null);
		
		tracker.open();
		
		Map<String, String> props = new HashMap<String, String>();
		props.put("key", "value");
		
		EventAdmin ea = (EventAdmin)tracker.getService();
		if(ea != null){
			ea.sendEvent(new Event("com/foo/bar", props));
		}
	}

	
	public void stop(BundleContext bundleContext) throws Exception {
	
	}

}
